//Let's look at the following string:
def input = 'abbbabaaabbabaaaabbaababaabaaaaaabbaaaababbabbbaabbbaabbabbbabbbabbaabababbbaabaaabaaaaaabbabaababbbaabbaabaaaaaabbaaaababbaabaaabbbabababbabbababbaaabaabbbaabaabbaaaababbbabaaabbaabab'

// Where to get started? The first thing to notice is that there are only two kinds of
// letters in the string. That should give you a clue as to how much signal each one
// represents. Now, what to do with the series? First, count how many letters there
// are. That number should give you a hint (try factoring it). Next, try to represent
// the data in a form that makes sense. The answer should become clear if you take
// the right approach. 

println input.count
def input2 = input.replace('a', '1').replace('b', '0')
def inputByte  = []
def inputByteIndex = 0
input2.eachWithIndex { bit, i ->
	if (inputByte[inputByteIndex] == null) inputByte[inputByteIndex] = bit 
	else inputByte[inputByteIndex] += bit 
	if (((i+1) % 8 == 0) & i > 0) {
		inputByteIndex++
	}
}

//TODO ASCII-Wert ermiteln
inputByte.each { bait -> 
	print Integer.parseInt(bait, 2) + ' ' 
}

println inputByte